import React from 'react';
import {QuestionInfoDefaultProps, QuestionInfoPropsType} from "./interface";
import {Typography} from "antd";

const {Title, Paragraph} = Typography
const Components: React.FC<QuestionInfoPropsType> = (props: QuestionInfoPropsType) => {
  const {title = '', desc = ''} = {...QuestionInfoDefaultProps, ...props}
  const textList = desc.split('\n')//根据\n拆分成数组 【‘hello’,'123','456'】

  return (
    <div>
      <Title style={{textAlign: 'center'}}>{title}</Title>
      <Paragraph style={{textAlign: 'center'}}>
        {textList.map((item, index) =>
            <span key={index}>
          {index > 0 && <br/>}
              {item}
        </span>
        )}</Paragraph>
    </div>
  );
};

export default Components;
